<?php 
function thumbyoutube($url,$width,$height,$id){
	$url2 = explode("v=",$url);
	if (strlen($url2[1]) > 11){
		$aux = explode("&",$url2[1]);
		$thumb = $aux[0];
	}else{
		$thumb = $url2[1];	
	}
	echo "<a class=\"thumbnail clearfix\" style=\"text-decoration:none;\" href=\"".$url."\" >";
	echo "<img src=\"http://img.youtube.com/vi/".$thumb."/2.jpg\" width=\"".$width."\" height=\"".$height."\" /></a>";
	
}
function embedVideo($url,$width,$height){
   if(preg_match("#http://(.*)\.youtube\.com/watch\?v=(.*)(&(.*))?#", $url, $matches)){
      echo '
            <object width="'.$width.'" height="'.$height.'">
               <param name="movie" value="http://www.youtube.com/v/'.$matches[2].'&hl=pt-br&fs=1"></param>
               <param name="allowFullScreen" value="true"></param>
               <param name="allowscriptaccess" value="always"></param>
               <embed src="http://www.youtube.com/v/'.$matches[2].'&hl=pt-br&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'.$width.'" height="'.$height.'"></embed>
            </object>
            ';
   }elseif(preg_match("#http://www\.metacafe\.com/watch/(([^/].*)/([^/].*))/?#", $url, $matches)){
      echo '<embed flashVars="playerVars=showStats=no|autoPlay=no|videoTitle="  src="http://www.metacafe.com/fplayer/'.$matches[1].'.swf" width="'.$width.'" height="'.$height.'" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>';
   }
}

?>